package robot;

import java.util.LinkedList;
import java.util.List;

import javax.swing.JTextArea;


public class RobotConsole {
	
	private JTextArea jTextArea;
	private List<String> list;
	
	public RobotConsole() {
		jTextArea = new JTextArea();
		list = new LinkedList<String>();
	}
	
	public void addText(String str) {
		list.add(str);
		if (list.size() > Const.LOG_LIMIT) {
			list.remove(0);
		}
		updateView();
	}
	
	public void updateView() {
		StringBuilder sb = new StringBuilder();
		for (String str : list) {
			sb.append(str);
			sb.append("\n");
		}
		jTextArea.setText(sb.toString());
	}
	
	public JTextArea getjTextArea() {
		return jTextArea;
	}

}
